import { axiosInstance } from "..";

function GetUinfoImprove(docid: string, username: string, seq: number,type:string) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/improveAchievement/improve/getuinfo", { docid, username, seq, type })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function GetImproveCount(docid: string) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/improveAchievement/improve/getseq", { docid })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function AddImproveLines(param: string) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/improveAchievement/improve/addlines", { param })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function GetImproveData(
  docid: string,
  search: string,
  type: string,
  seq: number
) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/improveAchievement/improve/getimprovedata", {
        docid,
        search,
        type,
        seq,
      })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function UpdateAccFlag(docid: string, seq: number, flow_code:string) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/improveAchievement/improve/updateaccflag", { docid, seq, flow_code })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

export {
  GetUinfoImprove,
  GetImproveCount,
  AddImproveLines,
  GetImproveData,
  UpdateAccFlag,
};
